#ifndef _DKGL_MATERIAL_H_
#define _DKGL_MATERIAL_H_

#include "dkglColor.h"
#include "dkglString.h"
#include "dkglPreRequest.h"
#include "dkglTexture.h"
#include "dkglFwdDec.h"
#include <boost/shared_ptr.hpp>


namespace DKGL
{
	class Material
	{
	public:
		
		Material()
		{}

		Material(const String& name);
		Material(const std::wstring& name, const Colorf&, const Colorf&, const Colorf&, float exp);
		Material(const Material&);
		~Material();

		void setColor(const Colorf& color);
		void setColor(float r, float g, float b);

		inline void setRenderMode(RENDER_MODE renderMode)
		{
			_renderMode = renderMode;
		}

		inline void enableDepthTest(bool b = true)
		{
			_enableDepthTest = b;
		}

		inline void setFrontFaceWinding(FRONT_FACE_WINDING_DIRECTION ffwd)
		{
			_frontFaceWinding = ffwd;
		}

		void setTexture(TexturePtr);

		Material& setAmbient(const Colorf&);
		Material& setAmbient(float r, float g, float b, float a = 1.0f);
		Material& setDiffuse(const Colorf&);
		Material& setDiffuse(float r, float g, float b, float a = 1.0f);
		Material& setSpecular(const Colorf&, float exp);
		Material& setSpecular(float r, float g, float b, float a, float exp);

		void begin();
		void end();

	private:
		
		
		void _initDefaultVal();
		String			_name;
		Colorf			mAmbient;
		Colorf			mDiffuse;
		Colorf			mSpecular;
		Colorf			_color;

		

		TexturePtr		_texturePtr;
		bool			_hasTexture;

		bool			_enableDepthTest;
		bool			_enableBlend;

		bool		_enableLighting;

		RENDER_MODE		
			_renderMode;

		FRONT_FACE_WINDING_DIRECTION
			_frontFaceWinding;

		float			m_fExp;
	};

	typedef boost::shared_ptr<Material> MaterialPtr;

}

#endif